/*
 * Exception.cpp
 *
 *  Created on: Feb 11, 2011
 *      Author: alki
 */

#include "Exception.h"

#include <stdio.h>

using namespace std;

Exception::Exception(Exception *parent,string file,int line,string error,string detail,string info) {
	this->m_parent = parent;
	this->m_file = file;
	this->m_line = line;
	this->m_error = error;
	this->m_detail = detail;
	this->m_info = info;
}

Exception::~Exception() {
	if(this->m_parent!=NULL)
		delete this->m_parent;
}

void Exception::out() {
	if(this->m_info.length()==0)
		cout << this->m_error << ": " << this->m_detail << " (" << this->m_file << ", " << this->m_line << ")" << endl;
	else
		cout << this->m_error << ": " << this->m_detail << " [" << this->m_info << "] (" << this->m_file << ", " << this->m_line << ")" << endl;

	if(this->m_parent!=NULL)
		this->m_parent->out();
}
